A draw context using a bitmap as it's back buffer. More...
Public Member Functions | |
CBitmap * | getBitmap () const |
virtual void | beginDraw () |
virtual void | endDraw () |
COffscreenContext Methods | |
void | copyFrom (CDrawContext *pContext, CRect destRect, CPoint srcOffset=CPoint(0, 0)) |
copy from offscreen to pContext | |
CCoord | getWidth () const |
CCoord | getHeight () const |
Draw primitives | |
virtual void | moveTo (const CPoint &point) |
move line position to point | |
virtual void | lineTo (const CPoint &point)=0 |
draw a line from current position to point | |
void | getLoc (CPoint &where) const |
virtual void | drawLines (const CPoint *points, const int32_t &numberOfLines)=0 |
draw multiple lines at once | |
virtual void | drawPolygon (const CPoint *pPoints, int32_t numberOfPoints, const CDrawStyle drawStyle=kDrawStroked)=0 |
draw a polygon | |
virtual void | drawRect (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)=0 |
draw a rect | |
virtual void | drawArc (const CRect &rect, const float startAngle1, const float endAngle2, const CDrawStyle drawStyle=kDrawStroked)=0 |
draw an arc, angles are in degree | |
virtual void | drawEllipse (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)=0 |
draw an ellipse | |
virtual void | drawPoint (const CPoint &point, const CColor &color)=0 |
draw a point | |
virtual void | drawBitmap (CBitmap *bitmap, const CRect &dest, const CPoint &offset=CPoint(0, 0), float alpha=1.f)=0 |
don't call directly, please use CBitmap::draw instead | |
virtual void | clearRect (const CRect &rect)=0 |
clears the rect (makes r = 0, g = 0, b = 0, a = 0) | |
Line Mode | |
virtual void | setLineStyle (const CLineStyle &style) |
set the current line style | |
const CLineStyle & | getLineStyle () const |
get the current line style | |
virtual void | setLineWidth (CCoord width) |
set the current line width | |
CCoord | getLineWidth () const |
get the current line width | |
Draw Mode | |
virtual void | setDrawMode (CDrawMode mode) |
set the current draw mode, see CDrawMode | |
CDrawMode | getDrawMode () const |
get the current draw mode, see CDrawMode | |
Clipping | |
virtual void | setClipRect (const CRect &clip) |
set the current clip | |
CRect & | getClipRect (CRect &clip) const |
get the current clip | |
virtual void | resetClipRect () |
reset the clip to the default state | |
Color | |
virtual void | setFillColor (const CColor &color) |
set current fill color | |
CColor | getFillColor () const |
get current fill color | |
virtual void | setFrameColor (const CColor &color) |
set current stroke color | |
CColor | getFrameColor () const |
get current stroke color | |
Font | |
virtual void | setFontColor (const CColor &color) |
set current font color | |
CColor | getFontColor () const |
get current font color | |
virtual void | setFont (const CFontRef font, const CCoord &size=0, const int32_t &style=-1) |
set current font | |
const CFontRef & | getFont () const |
get current font | |
Text | |
CCoord | getStringWidth (UTF8StringPtr pStr) |
get the width of an UTF-8 encoded string | |
void | drawString (UTF8StringPtr string, const CRect &_rect, const CHoriTxtAlign hAlign=kCenterText, bool antialias=true) |
draw an UTF-8 encoded string | |
void | drawString (UTF8StringPtr string, const CPoint &_point, bool antialias=true) |
draw an UTF-8 encoded string | |
Global Alpha State | |
virtual void | setGlobalAlpha (float newAlpha) |
sets the global alpha value[0..1] | |
float | getGlobalAlpha () const |
get current global alpha value | |
Global State Stack | |
virtual void | saveGlobalState () |
virtual void | restoreGlobalState () |
Offset Transformation | |
virtual void | setOffset (const CPoint &offset) |
const CPoint & | getOffset () const |
Reference Counting Methods | |
virtual void | forget () |
decrease refcount and delete object if refcount == 0 | |
virtual void | remember () |
increase refcount | |
virtual int32_t | getNbReference () const |
get refcount | |
Message Methods | |
virtual CMessageResult | notify (CBaseObject *sender, IdStringPtr message) |
Static Public Member Functions | |
static COffscreenContext * | create (CFrame *frame, CCoord width, CCoord height) |
Protected Member Functions | |
COffscreenContext (CBitmap *bitmap) | |
COffscreenContext (const CRect &surfaceRect) | |
~COffscreenContext () | |
virtual void | init () |
const CString & | getDrawString (UTF8StringPtr string) |
void | clearDrawString () |
Protected Attributes | |
CBitmap * | bitmap |
CString * | drawStringHelper |
CRect | surfaceRect |
CDrawContextState | currentState |
std::stack< CDrawContextState * > | globalStatesStack |
Graphics Paths | |
| |
virtual CGraphicsPath * | createGraphicsPath ()=0 |
create a graphics path object, you need to forget it after usage | |
CGraphicsPath * | createRoundRectGraphicsPath (const CRect &size, CCoord radius) |
create a rect with round corners as graphics path, you need to forget it after usage | |
virtual void | drawGraphicsPath (CGraphicsPath *path, PathDrawMode mode=kPathFilled, CGraphicsTransform *transformation=0)=0 |
virtual void | fillLinearGradient (CGraphicsPath *path, const CGradient &gradient, const CPoint &startPoint, const CPoint &endPoint, bool evenOdd=false, CGraphicsTransform *transformation=0)=0 |
enum | PathDrawMode { kPathFilled, kPathFilledEvenOdd, kPathStroked } |
A draw context using a bitmap as it's back buffer.
There are two usage scenarios :
COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100); if (offscreen) { offscreen->beginDraw (); // ... // draw into offscreen // ... offscreen->endDraw (); offscreen->copyFrom (otherContext, destRect); offscreen->forget (); }
if (cachedBitmap == 0) { COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100); if (offscreen) { offscreen->beginDraw (); // ... // draw into offscreen // ... offscreen->endDraw (); cachedBitmap = offscreen->getBitmap (); if (cachedBitmap) cachedBitmap->remember (); offscreen->forget (); } } if (cachedBitmap) { // ... }
enum PathDrawMode [inherited] |
COffscreenContext | ( | CBitmap * | bitmap | ) | [protected] |
COffscreenContext | ( | const CRect & | surfaceRect | ) | [protected] |
~COffscreenContext | ( | ) | [protected] |
virtual void beginDraw | ( | ) | [inline, virtual, inherited] |
void clearDrawString | ( | ) | [protected, inherited] |
virtual void clearRect | ( | const CRect & | rect | ) | [pure virtual, inherited] |
clears the rect (makes r = 0, g = 0, b = 0, a = 0)
void copyFrom | ( | CDrawContext * | pContext, | |
CRect | destRect, | |||
CPoint | srcOffset = CPoint (0, 0) | |||
) |
copy from offscreen to pContext
COffscreenContext * create | ( | CFrame * | frame, | |
CCoord | width, | |||
CCoord | height | |||
) | [static] |
virtual CGraphicsPath* createGraphicsPath | ( | ) | [pure virtual, inherited] |
create a graphics path object, you need to forget it after usage
CGraphicsPath * createRoundRectGraphicsPath | ( | const CRect & | size, | |
CCoord | radius | |||
) | [inherited] |
create a rect with round corners as graphics path, you need to forget it after usage
virtual void drawArc | ( | const CRect & | rect, | |
const float | startAngle1, | |||
const float | endAngle2, | |||
const CDrawStyle | drawStyle = kDrawStroked | |||
) | [pure virtual, inherited] |
draw an arc, angles are in degree
virtual void drawBitmap | ( | CBitmap * | bitmap, | |
const CRect & | dest, | |||
const CPoint & | offset = CPoint(0, 0) , |
|||
float | alpha = 1.f | |||
) | [pure virtual, inherited] |
don't call directly, please use CBitmap::draw instead
virtual void drawEllipse | ( | const CRect & | rect, | |
const CDrawStyle | drawStyle = kDrawStroked | |||
) | [pure virtual, inherited] |
draw an ellipse
virtual void drawGraphicsPath | ( | CGraphicsPath * | path, | |
PathDrawMode | mode = kPathFilled , |
|||
CGraphicsTransform * | transformation = 0 | |||
) | [pure virtual, inherited] |
virtual void drawLines | ( | const CPoint * | points, | |
const int32_t & | numberOfLines | |||
) | [pure virtual, inherited] |
draw multiple lines at once
draw a point
virtual void drawPolygon | ( | const CPoint * | pPoints, | |
int32_t | numberOfPoints, | |||
const CDrawStyle | drawStyle = kDrawStroked | |||
) | [pure virtual, inherited] |
draw a polygon
virtual void drawRect | ( | const CRect & | rect, | |
const CDrawStyle | drawStyle = kDrawStroked | |||
) | [pure virtual, inherited] |
draw a rect
void drawString | ( | UTF8StringPtr | string, | |
const CPoint & | _point, | |||
bool | antialias = true | |||
) | [inherited] |
draw an UTF-8 encoded string
void drawString | ( | UTF8StringPtr | string, | |
const CRect & | _rect, | |||
const CHoriTxtAlign | hAlign = kCenterText , |
|||
bool | antialias = true | |||
) | [inherited] |
draw an UTF-8 encoded string
virtual void endDraw | ( | ) | [inline, virtual, inherited] |
virtual void fillLinearGradient | ( | CGraphicsPath * | path, | |
const CGradient & | gradient, | |||
const CPoint & | startPoint, | |||
const CPoint & | endPoint, | |||
bool | evenOdd = false , |
|||
CGraphicsTransform * | transformation = 0 | |||
) | [pure virtual, inherited] |
virtual void forget | ( | ) | [inline, virtual, inherited] |
decrease refcount and delete object if refcount == 0
CBitmap* getBitmap | ( | ) | const [inline] |
const CString & getDrawString | ( | UTF8StringPtr | string | ) | [protected, inherited] |
CColor getFillColor | ( | ) | const [inline, inherited] |
get current fill color
const CFontRef& getFont | ( | ) | const [inline, inherited] |
get current font
CColor getFontColor | ( | ) | const [inline, inherited] |
get current font color
CColor getFrameColor | ( | ) | const [inline, inherited] |
get current stroke color
float getGlobalAlpha | ( | ) | const [inline, inherited] |
get current global alpha value
CCoord getHeight | ( | ) | const [inline] |
const CLineStyle& getLineStyle | ( | ) | const [inline, inherited] |
get the current line style
CCoord getLineWidth | ( | ) | const [inline, inherited] |
get the current line width
void getLoc | ( | CPoint & | where | ) | const [inline, inherited] |
virtual int32_t getNbReference | ( | ) | const [inline, virtual, inherited] |
get refcount
const CPoint& getOffset | ( | ) | const [inline, inherited] |
CCoord getStringWidth | ( | UTF8StringPtr | pStr | ) | [inherited] |
get the width of an UTF-8 encoded string
CCoord getWidth | ( | ) | const [inline] |
void init | ( | ) | [protected, virtual, inherited] |
virtual void lineTo | ( | const CPoint & | point | ) | [pure virtual, inherited] |
draw a line from current position to point
void moveTo | ( | const CPoint & | point | ) | [virtual, inherited] |
move line position to point
virtual CMessageResult notify | ( | CBaseObject * | sender, | |
IdStringPtr | message | |||
) | [inline, virtual, inherited] |
virtual void remember | ( | ) | [inline, virtual, inherited] |
increase refcount
void resetClipRect | ( | ) | [virtual, inherited] |
reset the clip to the default state
void restoreGlobalState | ( | ) | [virtual, inherited] |
void saveGlobalState | ( | ) | [virtual, inherited] |
void setClipRect | ( | const CRect & | clip | ) | [virtual, inherited] |
set the current clip
void setFillColor | ( | const CColor & | color | ) | [virtual, inherited] |
set current fill color
void setFont | ( | const CFontRef | font, | |
const CCoord & | size = 0 , |
|||
const int32_t & | style = -1 | |||
) | [virtual, inherited] |
set current font
void setFontColor | ( | const CColor & | color | ) | [virtual, inherited] |
set current font color
void setFrameColor | ( | const CColor & | color | ) | [virtual, inherited] |
set current stroke color
void setGlobalAlpha | ( | float | newAlpha | ) | [virtual, inherited] |
sets the global alpha value[0..1]
void setLineStyle | ( | const CLineStyle & | style | ) | [virtual, inherited] |
set the current line style
void setLineWidth | ( | CCoord | width | ) | [virtual, inherited] |
set the current line width
void setOffset | ( | const CPoint & | offset | ) | [virtual, inherited] |
CDrawContextState currentState [protected, inherited] |
CString* drawStringHelper [protected, inherited] |
std::stack<CDrawContextState*> globalStatesStack [protected, inherited] |
CRect surfaceRect [protected, inherited] |